var app=getApp();
Page({

  /**
   * 页面的初始数据
   */
  data: {
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    var bgc = wx.getStorageSync('color')
    wx.setNavigationBarColor({
      frontColor: "#ffffff",
      backgroundColor: bgc,
    })
    var that = this;
    var ty_id = options.ty_id;
    this.getTijian_yiyuanxq(ty_id);
    this.getTijian_yiyuantaocanlist(ty_id);
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {
  
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
  
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {
  
  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {
  
  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {
    wx.showNavigationBarLoading();
    setTimeout(function () {
      wx.hideNavigationBarLoading();
      wx.stopPullDownRefresh();
    }, 1000);
    var that = this;
    var ty_id = data.ty_id;
    this.getTijian_yiyuanxq(ty_id);
  },
  getTijian_yiyuanxq: function (ty_id) {
    var that = this;
    console.log(app);
    app.util.request({
      'url': 'entry/wxapp/Tijian_yiyuanxq',
      'data': {
        ty_id: ty_id,
      },
      'cachetime': '30',
      success: function (res) {
        that.setData({
          tijian_yiyuanxq: res.data.data,

        })
        wx.setNavigationBarTitle({ title: that.data.tijian_yiyuanxq.ty_name });
      },
      fail: function (err) {
        console.log(err)
      },

    })
  },
  getTijian_yiyuantaocanlist: function (ty_id) {
    var that = this;
    console.log(app);
    app.util.request({
      'url': 'entry/wxapp/Tijian_yiyuantaocanlist',
      'data': {
        ty_id: ty_id,
      },
      'cachetime': '30',
      success: function (res) {
        that.setData({
          tijian_yiyuantaocanxq: res.data.data,

        })
      },
      fail: function (err) {
        console.log(err)
      },

    })
  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {
  
  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {
  
  },
  tjxqClick: function (event) {
    var tt_id = event.currentTarget.dataset.tt_id;
    var ty_id = event.currentTarget.dataset.ty_id;
    wx: wx.navigateTo({
      url: '../tcxq/tcxq?tt_id='+tt_id+"&ty_id="+ty_id,
    })
  },
  //地图
  mapClick: function () {
    this.openMap();
  },
    openMap: function (e) {
    var that = this;
    wx.openLocation({
      latitude: parseFloat(that.data.tijian_yiyuanxq.latitude),
      longitude: parseFloat(that.data.tijian_yiyuanxq.longitude),
      //name: that.data.baseinfo.name,
      address: that.data.tijian_yiyuanxq.ty_address,
      scale: 22
    });
  },
})